package com.example.demo.controller;


import com.example.demo.entity.vo.GroupInput;
import com.example.demo.entity.vo.GroupOutput;
import com.example.demo.service.GroupInfoService;
import com.example.demo.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author chen huilong
 * @since 2022-10-04
 */
@Api(tags = "队伍信息管理")
@RestController
@RequestMapping("/demo/group-info")
public class GroupInfoController {

    @Resource
    private GroupInfoService groupInfoService;

    @PostMapping("/groupByVerificationCode")
    @ApiOperation(value = "添加队伍成员", notes = "通过学号与验证码添加队伍成员")
    public Response groupByVerificationCode(@RequestHeader("token") String token, @RequestBody GroupInput input) {
        List<GroupOutput> list = groupInfoService.groupByVerificationCode(token, input);
        return Response.success().data("group list", list);
    }


    @PostMapping("/getRoommateInfo")
    @ApiOperation(value = "查询宿舍与舍友信息", notes = "")
    public Response getRoommateInfo(@RequestHeader("token") String token) {
        HashMap<String, Object> list = groupInfoService.getRoommateInfo(token);
        return Response.success().data(list);
    }

}

